#include <vector>

using namespace std;

class NumArray {
private:
    vector<int> sum;
public:
    NumArray(vector<int>& nums) {
        if (nums.size() == 0) {
            return;
        }
        sum.resize(nums.size());
        sum[0] = nums[0];
        for (int i = 1; i < nums.size(); i++) {
            sum[i] = sum[i - 1] + nums[i];
        }
    }

    int sumRange(int i, int j) {
        if (i == 0) {
            return sum[j];
        }
        return sum[j] - sum[i - 1];
    }
};
